{
dom0_physinfo_t *pi = &op->u.physinfo;
- pi->threads_per_core = smp_num_siblings;
- pi->cores_per_socket = boot_cpu_data.x86_max_cores;
+ pi->threads_per_core =
+ cpus_weight(cpu_sibling_map[0]);
+ pi->cores_per_socket =
+ cpus_weight(cpu_core_map[0]) / pi->threads_per_core;
pi->sockets_per_node =
- num_online_cpus() / (pi->threads_per_core * pi->cores_per_socket);
+ num_online_cpus() / cpus_weight(cpu_core_map[0]);
+
pi->nr_nodes = 1;
pi->total_pages = total_pages;
pi->free_pages = avail_domheap_pages();
domid_t dom;
struct vcpu *v;
unsigned int i, cnt[NR_CPUS] = { 0 };
+ cpumask_t cpu_exclude_map;
static domid_t rover = 0;
dom = op->u.createdomain.domain;
read_lock(&domlist_lock);
for_each_domain ( d )
for_each_vcpu ( d, v )
- cnt[v->processor]++;
+ if ( !test_bit(_VCPUF_down, &v->vcpu_flags) )
+ cnt[v->processor]++;
read_unlock(&domlist_lock);
/*
- * If we're on a HT system, we only use the first HT for dom0, other
- * domains will all share the second HT of each CPU. Since dom0 is on
- * CPU 0, we favour high numbered CPUs in the event of a tie.
+ * If we're on a HT system, we only auto-allocate to a non-primary HT.
+ * We favour high numbered CPUs in the event of a tie.
*/
- pro = smp_num_siblings - 1;
- for ( i = pro; i < num_online_cpus(); i += smp_num_siblings )
+ pro = first_cpu(cpu_sibling_map[0]);
+ if ( cpus_weight(cpu_sibling_map[0]) > 1 )
+ pro = next_cpu(pro, cpu_sibling_map[0]);
+ cpu_exclude_map = cpu_sibling_map[0];
+ for_each_online_cpu ( i )
+ {
+ if ( cpu_isset(i, cpu_exclude_map) )
+ continue;
+ if ( (i == first_cpu(cpu_sibling_map[i])) &&
+ (cpus_weight(cpu_sibling_map[i]) > 1) )
+ continue;
+ cpus_or(cpu_exclude_map, cpu_exclude_map, cpu_sibling_map[i]);
if ( cnt[i] <= cnt[pro] )
pro = i;
+ }
ret = -ENOMEM;
if ( (d = domain_create(dom, pro)) == NULL )